package com.example.wei.mvp.ui.activity;

import android.annotation.TargetApi;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Handler;
import android.view.Window;
import android.view.WindowManager;

import com.example.wei.mvp.R;
import com.example.wei.mvp.base.BaseActivity;
import com.example.wei.mvp.component.AppComponent;
import com.example.wei.mvp.component.DaggerMainComponent;
import com.example.wei.mvp.util.SPUtils;
import com.githang.statusbar.StatusBarCompat;


/**
 * Created by Administrator on 2017/10/31 0031.
 */
public class WelcomeActivity extends BaseActivity {
    private boolean firstLogin=false;
    @Override
    public int getLayoutId() {
        setTranslucentStatus();
        return R.layout.activity_welcome;
    }

    @Override
    protected void attachView() {

    }

    @Override
    protected void innitView() {
        StatusBarCompat.setStatusBarColor(this, Color.parseColor("#00000000"), true);
       // firstLogin = (boolean) SPUtils.get("isFirst",true);
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                goNextUi();
            }
        },1000);
    }
    @Override
    protected void innitData() {

    }

    @Override
    protected void setupActivityComponent(AppComponent appComponent) {
        DaggerMainComponent.builder().appComponent(appComponent).build().inject(this);
    }

    //设置系统状态栏
    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    private void setTranslucentStatus() {
        //判断版本是4.4以上
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            Window win = getWindow();
            WindowManager.LayoutParams winParams = win.getAttributes();
            final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
            winParams.flags |= bits;
            win.setAttributes(winParams);
        }else{
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }
    }

    private void goNextUi() {
        if (firstLogin) {
           startActivity(new Intent(this,GuidanceActivity.class));
        }else {
          startActivity(new Intent(this,MainActivity.class));

        }
        finish();
    }


}
